class Solution(object):
def rotatedDigits\(self, N\):
"""
:type N: int
:rtype: int
"""
valid=\[2, 5, 6, 9\]
que=\[8,1,0\]
i=1
count=0
Pos=False
while i<=N:
temp=i
Pos=False
while temp>0:
if \(temp%10\) in valid:
Pos=True
temp=temp/10
elif \(temp % 10\) in que:
Pos= Pos
temp=temp/10
else:
Pos=False
break
if Pos:
count+=1
i+=1
else:
i+=1
return count